home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: A weird thing about printf()
- Date: 10 Apr 1996 07:46 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <10APR199607465823@erich.triumf.ca>
- References: <4kflr2$5if@dewey.csun.edu>
- NNTP-Posting-Host: ftp.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4kflr2$5if@dewey.csun.edu>, kc44097@csun.edu (chen) writes...
-
- >#include <stdio.h>
- >int answer;
- >main()
- >{
- > answer=2+2;
- > printf("The answer is %d\n");
- > return 0;
- >}
- >
- > In printf(),I lost "answer" in the end,but it works,and give me the
- >result 0.I wonder how the compiler handle this condition.Also,is this
- >allow by C?(by this, I mean is this a leagal usage in language itself,
- >or just a mistake cause by the compiler?)
-
- Many compilers don't check that you gave printf() the appropriate type or
- number of arguments to match the print specifiers, so they won't give any error
- or warning message for this.
-
- It's a mistake by the _programmer_, not by the compiler.
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-
-
-
-